home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH06 / PROJ6_5.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-02-04  |  1.9 KB  |  115 lines

  1. ; PROJ6_5.ASM-
  2. ;
  3. ; An integer output routine.
  4. ;
  5. ; PUTINT is passed an unsigned integer value in the AX register.
  6. ; It should print the value of that integer as a sequence of characters
  7. ; providing the decimal representation of that integer.  See the lab
  8. ; manual for the exact algorithm.
  9.  
  10.  
  11.  
  12. dseg        segment    para public 'data'
  13. ; Put any variables you need here.
  14. dseg        ends
  15.  
  16. cseg        segment    para public 'code'
  17.         assume    cs:cseg, ds:dseg
  18.  
  19.  
  20. ; PutChar prints the character in the AL register to the display.
  21.  
  22. PutChar        proc
  23.         push    ax        ;Preserve value in AH
  24.         mov    ah, 0eh        ;BIOS call to print a character.
  25.         int    10h
  26.         pop    ax        ;Restore AH's value.
  27.         ret
  28. PutChar        endp
  29.  
  30.  
  31. ; Newline-    Prints the cr/lf pair to the screen (a new line).
  32.  
  33. NewLine        proc
  34.         push    ax
  35.         mov    ax, 0e0dh    ;Carriage return
  36.         int    10h
  37.         mov    ax, 0e0ah    ;Linefeed
  38.         int    10h
  39.         pop    ax
  40.         ret
  41. NewLine        endp
  42.  
  43.  
  44.  
  45. ; Here is the routine you've got to write for this project.
  46. ; On entry, AX contains an unsigned integer value.  It needs to
  47. ; print this value as a string of decimal digits.  Be sure to
  48. ; preserve (on the stack) all registers you modify.
  49.  
  50. PutInt        proc
  51.         ret
  52. PutInt        endp
  53.  
  54.  
  55.  
  56.  
  57. ; Main program to test the PutInt routine.
  58.  
  59. Main        proc
  60.         mov    ax, dseg
  61.         mov    ds, ax
  62.  
  63.  
  64.         mov    ax, 12345
  65.         call    PutInt
  66.         call    NewLine
  67.  
  68.         mov    ax, 54321
  69.         call    PutInt
  70.         call    NewLine
  71.  
  72.         mov    ax, 0
  73.         call    PutInt
  74.         call    NewLine
  75.  
  76.         mov    ax, 65535
  77.         call    PutInt
  78.         call    NewLine
  79.  
  80.         mov    ax, 1
  81.         call    PutInt
  82.         call    NewLine
  83.  
  84.         mov    ax, 10
  85.         call    PutInt
  86.         call    NewLine
  87.  
  88.         mov    ax, 100
  89.         call    PutInt
  90.         call    NewLine
  91.  
  92.         mov    ax, 1000
  93.         call    PutInt
  94.         call    NewLine
  95.  
  96.         mov    ax, 10000
  97.         call    PutInt
  98.         call    NewLine
  99.  
  100.  
  101. Quit:        mov    ah, 4ch          ;DOS opcode to quit program.
  102.         int    21h        ;Call DOS.
  103. Main        endp
  104.  
  105. cseg        ends
  106.  
  107. sseg        segment    para stack 'stack'
  108. stk        byte    1024 dup ("stack   ")
  109. sseg        ends
  110.  
  111. zzzzzzseg    segment    para public 'zzzzzz'
  112. LastBytes    byte    16 dup (?)
  113. zzzzzzseg    ends
  114.         end    Main
  115.